package com.aboverock.core.orm.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import java.util.Date;

/**
 * The Class BaseEntity.
 *
 * @author Rock Wang
 */
public abstract class BaseEntity<ID extends Serializable> {

    /** 创建时间. */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    /** 创建用户. */
    @TableField(value = "create_user", fill = FieldFill.INSERT)
    private String createUser;

    /** 更新时间. */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /** 更新用户. */
    @TableField(value = "update_user", fill = FieldFill.UPDATE)
    private String updateUser;

    /** 状态 0:正常，1:删除. */
    @TableLogic
    @TableField(value = "deleted", fill = FieldFill.INSERT)
    @JsonIgnore
    private Integer deleted;

    /** The version. */
    @Version
    @TableField(value = "version", fill = FieldFill.INSERT)
    private Integer version;

    /**
     * Gets the id.
     *
     * @return the id
     */
    public abstract ID getId();

    /**
     * Sets the id.
     *
     * @param id the new id
     */
    public abstract void setId(ID id);

    /**
     * Gets the creates the time.
     *
     * @return the creates the time
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * Sets the creates the time.
     *
     * @param createTime the new creates the time
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * Gets the creates the user.
     *
     * @return the creates the user
     */
    public String getCreateUser() {
        return createUser;
    }

    /**
     * Sets the creates the user.
     *
     * @param createUser the new creates the user
     */
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    /**
     * Gets the update time.
     *
     * @return the update time
     */
    public Date getUpdateTime() {
        return updateTime;
    }

    /**
     * Sets the update time.
     *
     * @param updateTime the new update time
     */
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * Gets the update user.
     *
     * @return the update user
     */
    public String getUpdateUser() {
        return updateUser;
    }

    /**
     * Sets the update user.
     *
     * @param updateUser the new update user
     */
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }

    /**
     * Gets the deleted.
     *
     * @return the deleted
     */
    public Integer getDeleted() {
        return deleted;
    }

    /**
     * Sets the deleted.
     *
     * @param deleted the new deleted
     */
    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }

    /**
     * Gets the version.
     *
     * @return the version
     */
    public Integer getVersion() {
        return version;
    }

    /**
     * Sets the version.
     *
     * @param version the new version
     */
    public void setVersion(Integer version) {
        this.version = version;
    }

    public static class FieldMapping {
        public static final String ID = "id";

        public static final String CREATE_TIME = "create_time";

        public static final String CREATE_USER = "create_user";

        public static final String UPDATE_TIME = "update_time";

        public static final String UPDATE_USER = "update_user";

        public static final String DELETED = "deleted";

        public static final String VERSION = "version";
    }
}
